package com.ruoyi.boss.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.boss.domain.TFench;
import com.ruoyi.boss.service.ITFenchService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 下单围栏列表优化Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/fench")
public class TFenchController extends BaseController
{
    @Autowired
    private ITFenchService tFenchService;

    /**
     * 查询下单围栏列表优化列表
     */
    @RequiresPermissions("boss:fench:list")
    @GetMapping("/list")
    public TableDataInfo list(TFench tFench)
    {
        startPage();
        List<TFench> list = tFenchService.selectTFenchList(tFench);
        return getDataTable(list);
    }

    /**
     * 导出下单围栏列表优化列表
     */
    @RequiresPermissions("boss:fench:export")
    @Log(title = "下单围栏列表优化", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TFench tFench)
    {
        List<TFench> list = tFenchService.selectTFenchList(tFench);
        ExcelUtil<TFench> util = new ExcelUtil<TFench>(TFench.class);
        util.exportExcel(response, list, "下单围栏列表优化数据");
    }

    /**
     * 获取下单围栏列表优化详细信息
     */
    @RequiresPermissions("boss:fench:query")
    @GetMapping(value = "/{fenchId}")
    public AjaxResult getInfo(@PathVariable("fenchId") Long fenchId)
    {
        return success(tFenchService.selectTFenchByFenchId(fenchId));
    }

    /**
     * 新增下单围栏列表优化
     */
    @RequiresPermissions("boss:fench:add")
    @Log(title = "下单围栏列表优化", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TFench tFench)
    {
        return toAjax(tFenchService.insertTFench(tFench));
    }

    /**
     * 修改下单围栏列表优化
     */
    @RequiresPermissions("boss:fench:edit")
    @Log(title = "下单围栏列表优化", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TFench tFench)
    {
        return toAjax(tFenchService.updateTFench(tFench));
    }

    /**
     * 删除下单围栏列表优化
     */
    @RequiresPermissions("boss:fench:remove")
    @Log(title = "下单围栏列表优化", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fenchIds}")
    public AjaxResult remove(@PathVariable Long[] fenchIds)
    {
        return toAjax(tFenchService.deleteTFenchByFenchIds(fenchIds));
    }
}
